<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
  // 冒泡排序：当前与下一个比较，比下一个大就进行交换，isSort：没有排序的时候证明已经有序，直接跳出循环

    function bubblingSorting(arr){
      const len = arr.length

      for(let i = 0;i < len - 1;i++){
        let isSort = false
        for(let j = 0;j < len - i - 1;j++){
          if (arr[j] > arr[j + 1]){
            [arr[j],arr[j + 1]] = [arr[j + 1],arr[j]]
            isSort = true
          }
        }
        if (!isSort){
          break
        }
      }
      return arr
    }

    console.log(bubblingSorting([2,5,3,7,9,7,3,2,9,0,10,2,3,5,2,32,53]))
</script>
</html>